#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

void* my_memcpy(void* dest, const void* src, size_t count)
{
	void* ret = dest;
	while (count--)
	{
		*(char*)dest = *(char*)src;
		dest = (char*)dest + 1;
		src = (char*)src + 1;
	}
	return ret;
}

void* my_memmove(void* dest, const* src, size_t count)
{
	void* ret = dest;
	if (dest <= src || (char*)dest >= (char*)src + count)
	{
		while (count--)
		{
			*(char*)dest =* (char*)src;
			dest = (char*)dest + 1;
			src = (char*)src + 1;
		}
	}

	else
	{

		dest = (char*)dest + count - 1;
		src = (char*)src + count - 1;

		while (count--)
		{
			*(char*)dest = *(char*)src;
			dest = (char*)dest -1;		
			src = (char*)src -1;

		
		}

	}

	return ret;

}



int main()
{
	char str1[] = "hello";
	char str2[] = "world";
	//my_memcpy(str1, str2,5);

	my_memmove(str1, str1 + 2, 2);
	printf("%s", str1);

	return 0;
}